package com.UI;

import java.util.ArrayList;
import java.util.List;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import android.content.Context;


/* Author : Mohammed
 * 
 * ListView GUI Optimization
 * Implements a custom ListView for themes,background and style
 * 
 */

class CourseAdapter extends ArrayAdapter<String> {

        private static List<String> records;

        public 	CourseAdapter(Context context, int textViewResourceId, List<String> records) {
                super(context, textViewResourceId, records);
                this.records = records;
        }
        @Override
        public View getView(int position, View convertView, ViewGroup parent) {
                View v = convertView;
                if (v == null) {
                    LayoutInflater vi = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

                    v = vi.inflate(R.layout.course_row, null);
                }
                String s = records.get(position);
                if (s != null) {
                        TextView courseCode = (TextView) v.findViewById(R.id.list_record);
                        courseCode.setTextAppearance( getContext(), R.style.SpecialText );
                        
                        if (courseCode != null) {
                        	courseCode.setText(s);                            }

                }
                return v;
        }
        
}     